package com.lf.web.service.system.menu;

import com.lf.connect.MongoDB;
import com.lf.data.Cluster;
import com.lf.data.CollectionDAO;
import com.lf.data.search.Query;
import com.lf.data.search.Sort;

import java.util.List;

public class MenuDAO extends CollectionDAO {

    public static final String COLLECTION = "c_menu";

    public MenuDAO(MongoDB nosql) {
        super(nosql, COLLECTION);
    }

    public List<Cluster> findByParentid(String pid) {
        Query query = new Query();
        query.idEQ(Menu.PARENT_ID, pid);
        Sort sort = new Sort();
        sort.desc(Menu.INDEX);
        return this.find(query, null, sort);
    }
}